<style lang="scss" scoped>
.book {
  padding: 20px;
  dl {
    line-height: 20px;
    dt {
      margin: 10px 0;
      font-size: 18px;
    }
    dd {
      font-size: 14px;
    }
  }
}
</style>
<template>
  <van-cell-group inset>
    <van-cell title="共找到关结果2000条" />
    
  </van-cell-group>
  <van-list
    v-model:loading="loading"
    :finished="finished"
    finished-text="没有更多了"
    @load="onLoad"
  >
    <div class="book">
      <dl v-for="(v, i) in SearchBookData" :key="i" :v="v" @click="KPdetail(v)">
        <dt>
          {{ v.texttitle }}
        </dt>
        <dd>
          <van-text-ellipsis :content="v.textdescword" rows="2" />
          <div class="name">
            <van-tag type="success">{{ v.texttype }}</van-tag>
          </div>
        </dd>
      </dl>
    </div>
  </van-list>
</template>
<script setup lang="ts">
import { onMounted, ref, reactive } from 'vue'
import axios from 'axios'
import type { bookStata, doctorState, socoState } from '@/interface'
import { useRoute, useRouter } from 'vue-router'
const router = useRouter()
const SearchBookData = ref<bookStata[]>([])
const SearchDoctorData = ref<doctorState[]>([])
const SearchSocoData = ref<socoState[]>([])
const route = useRoute()
const loading = ref(true)
const finished = ref(false)
const config = reactive({
  pageCode: 1,
  pageSize: 10,
})
const onLoad = () => {
  config.pageCode++
  loading.value = true
  getList()
}

onMounted(() => {
  route.query.searchValue
  console.log(route.query.searchValue)
  getList()
})

const getList = () => {
  axios
    .get('/api/search', {
      params: {
        pageCode: config,
        pageSize: 10,
        searchValue: route.query.searchValue,
      },
    })
    .then(res => {
      let { data } = res.data
      console.log(data)

      SearchBookData.value = [...SearchBookData.value, ...data.book]
      SearchDoctorData.value = data.doctor
      SearchSocoData.value = data.soco
      loading.value = false
    })
}
getList()
const KPdetail = (v: bookStata) => {
  router.push({
    path: `/detail2/${v.textid}`,
  })
}
</script>


<!-- <style scoped lang="scss">
    
</style>
<template>
    <two :cc="www" @on-Name="aa"></two>
    
</template>

<script setup lang="ts">
import two from '@/components/two/index.vue'
import { ref } from 'vue';

const www=ref('hhh')
const aa=()=>{
    www.value='2222'
}
</script> -->
